package com.thinkgem.jeesite.common.utils.wx;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * User: Egan
 * Date: 2017/01/18
 * Time: 14:18
 */
public class RandomStringGenerator {

    /**
     * 获取一定长度的随机字符串
     * @param length 指定字符串长度
     * @return 一定长度的字符串
     */
    public static String getRandomStringByLength(int length) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

    public static String getDay() throws Exception {
    	SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date date= myFormatter.parse( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 
        java.util.Date mydate= myFormatter.parse("1970-01-01 00:00:00");
        long day=(date.getTime()-mydate.getTime());
        return day/1000+"";
    }
    
}
